#ifndef _GEOMETRY_H
#define _GEOMETRY_H

#include "GlobalDefines.h"
class Geometry
{
public:
	Geometry(){};
	virtual ~Geometry(){};
	virtual void ReadGeometry(char* GeoName,emx::Real3D Shift) = 0;
protected:
	std::ifstream fin;
};

class TriangleMesh:public Geometry
{
protected:
	struct node{
		emx::Real3D Position;
		int Idx;
	};
	struct facet{
		blitz::TinyVector<node*,3> Vertex;
		blitz::TinyVector<emx::Real3D,4> Point;
		emx::real_data Area;
		emx::Real3D Center, Normal;
		int Idx;
	};
	struct edge{
		emx::real_data EdgeLength;
		node *BeginVertex, *EndVertex;
		facet *LeftFacet, *RightFacet;
		emx::Real3D Rho_plus, Rho_minus, LeftPoint, RightPoint, MidPoint;
		int Idx;
	};
public:
	TriangleMesh(emx::MediumType medium):Medium(medium){};
	virtual ~TriangleMesh(){};
	void ReadGeometry(char* GeoName,emx::Real3D Shift);
	const int GetPatchNum() const{return Patch_Num;}
	const int GetEdgeNum() const{return Edge_Num;}
	const node* GetNode(const int Idx) const{return Node(Idx);}
	const edge* GetEdge(const int Idx) const{return Edge(Idx);}
	const facet* GetPatch(const int Idx) const{return Patch(Idx);}
private:
	bool ReadNodes(emx::Real3D Shift);
	bool ReadPatchs();
	bool ReadEdges();
private:
	emx::MediumType Medium;
	int Node_Num, Patch_Num, Edge_Num;
	blitz::Array<node*, 1> Node;			
	blitz::Array<edge*, 1> Edge;
	blitz::Array<facet*, 1> Patch;
};

#endif
